package com.docker.fjk.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.docker.common.annotation.Log;
import com.docker.common.core.controller.BaseController;
import com.docker.common.core.domain.AjaxResult;
import com.docker.common.enums.BusinessType;
import com.docker.fjk.domain.fjkDoctorPatient;
import com.docker.fjk.service.fjkIDoctorPatientService;
import com.docker.common.utils.poi.ExcelUtil;
import com.docker.common.core.page.TableDataInfo;

/**
 * 患者统计Controller
 * 
 * @author ruoyi
 * @date 2025-04-14
 */
@RestController
@RequestMapping("/statistics/statistics")
public class fjkDoctorPatientController extends BaseController
{
    @Autowired
    private fjkIDoctorPatientService doctorPatientService;

    /**
     * 查询患者统计列表
     */
    @PreAuthorize("@ss.hasPermi('statistics:statistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(fjkDoctorPatient doctorPatient)
    {
        startPage();
        List<fjkDoctorPatient> list = doctorPatientService.selectDoctorPatientList(doctorPatient);
        return getDataTable(list);
    }

    /**
     * 导出患者统计列表
     */
    @PreAuthorize("@ss.hasPermi('statistics:statistics:export')")
    @Log(title = "患者统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, fjkDoctorPatient doctorPatient)
    {
        List<fjkDoctorPatient> list = doctorPatientService.selectDoctorPatientList(doctorPatient);
        ExcelUtil<fjkDoctorPatient> util = new ExcelUtil<fjkDoctorPatient>(fjkDoctorPatient.class);
        util.exportExcel(response, list, "患者统计数据");
    }

    /**
     * 获取患者统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('statistics:statistics:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(doctorPatientService.selectDoctorPatientById(id));
    }

    /**
     * 新增患者统计
     */
    @PreAuthorize("@ss.hasPermi('statistics:statistics:add')")
    @Log(title = "患者统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody fjkDoctorPatient doctorPatient)
    {
        return toAjax(doctorPatientService.insertDoctorPatient(doctorPatient));
    }

    /**
     * 修改患者统计
     */
    @PreAuthorize("@ss.hasPermi('statistics:statistics:edit')")
    @Log(title = "患者统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody fjkDoctorPatient doctorPatient)
    {
        return toAjax(doctorPatientService.updateDoctorPatient(doctorPatient));
    }

    /**
     * 删除患者统计
     */
    @PreAuthorize("@ss.hasPermi('statistics:statistics:remove')")
    @Log(title = "患者统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(doctorPatientService.deleteDoctorPatientByIds(ids));
    }
}
